package com.ruoyi.web.controller.base;

import com.ruoyi.base.domain.BusWaterfuncarea;
import com.ruoyi.base.service.BusWaterfuncareaService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 水功能区
 */
@RestController
@RequestMapping("/bus/waterfuncarea")
public class BusWaterfuncareaController extends BaseController {


    @Autowired
    private BusWaterfuncareaService busWaterfuncareaService;
    /**
     * 查询水功能区列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BusWaterfuncarea wqBaseWaterfuncarea)
    {
        startPage();
        List<BusWaterfuncarea> list = busWaterfuncareaService.selectWqBaseWaterfuncareaList(wqBaseWaterfuncarea);
        return getDataTable(list);
    }

    /**
     * 导出水功能区列表
     */
    @Log(title = "水功能区", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterfuncarea wqBaseWaterfuncarea)
    {
        List<BusWaterfuncarea> list = busWaterfuncareaService.selectWqBaseWaterfuncareaList(wqBaseWaterfuncarea);
        ExcelUtil<BusWaterfuncarea> util = new ExcelUtil<BusWaterfuncarea>(BusWaterfuncarea.class);
        util.exportExcel(response, list, "水功能区数据");
    }

    /**
     * 获取水功能区详细信息
     */
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(busWaterfuncareaService.selectWqBaseWaterfuncareaById(id));
    }

    /**
     * 新增水功能区
     */
    @Log(title = "水功能区", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusWaterfuncarea wqBaseWaterfuncarea)
    {
        return toAjax(busWaterfuncareaService.insertWqBaseWaterfuncarea(wqBaseWaterfuncarea));
    }

    /**
     * 修改水功能区
     */
    @Log(title = "水功能区", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusWaterfuncarea wqBaseWaterfuncarea)
    {
        return toAjax(busWaterfuncareaService.updateWqBaseWaterfuncarea(wqBaseWaterfuncarea));
    }

    /**
     * 删除水功能区
     */
    @Log(title = "水功能区", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busWaterfuncareaService.deleteWqBaseWaterfuncareaByIds(ids));
    }
}
